package org.patchca.utils.encoder;

import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import org.patchca.service.Captcha;
import org.patchca.service.CaptchaService;

public class EncoderHelper
{
    public static String getChallangeAndWriteImage(CaptchaService service,
            String format, OutputStream os) throws IOException
    {
        Captcha captcha = service.getCaptcha();
        ImageIO.write(captcha.getImage(), format, os);
        return captcha.getChallenge();
    }
}
